package com.ie.controller.admin;

import com.ie.common.http.ResponseResult;
import com.ie.common.security.anno.AuthIgrone;
import com.ie.entity.AUserEntity;
import com.ie.service.admin.AUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/api/admin")
public class AUserController {
    @Autowired
    private AUserService AUserService; // 修改为小写开头

    @AuthIgrone
    @RequestMapping("/login")
    public ResponseResult<Map<String,String>> login(@RequestBody AUserEntity aUserEntity){
        return AUserService.login(aUserEntity); // 修改调用的变量名
    }

    @AuthIgrone
    @PostMapping("/changePassword")
    public ResponseResult<Map<String, String>> changePassword(@RequestBody Map<String, String> params) {
        String username = params.get("username");
        String oldPassword = params.get("oldPassword");
        String newPassword = params.get("newPassword");
        return com.ie.service.admin.AUserService.changePassword(username, oldPassword, newPassword); // 修改调用的变量名
    }
}
